<template>
  <div>
    客户修改页面
    <el-form label-position="right" label-width="180px" :model="client">
      <el-form-item label="客户名称">
        <el-input v-model="client.cname"></el-input>
      </el-form-item>
      <el-form-item label="客户公司地址">
        <el-input v-model="client.site"></el-input>
      </el-form-item>
      <el-form-item label="客户邮政编码">
        <el-input v-model="client.postal"></el-input>
      </el-form-item>
      <el-form-item label="客户公司规模">
        <el-select v-model="client.scale" style="width: 100%">
          <el-option label="特大型" value="特大型"></el-option>
          <el-option label="大型" value="大型"></el-option>
          <el-option label="中型" value="中型"></el-option>
          <el-option label="小型" value="小型"></el-option>
          <el-option label="微型" value="微型"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="客户公司业务区域">
        <el-input v-model="client.area"></el-input>
      </el-form-item>
      <el-form-item label="客户等级">
        <el-select v-model="client.grade" style="width:100%">
          <el-option label="1级" value="1"></el-option>
          <el-option label="2级" value="2"></el-option>
          <el-option label="3级" value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="联系人">
        <el-input v-model="client.contacts"></el-input>
      </el-form-item>
      <el-form-item label="联系电话">
        <el-input v-model="client.phone"></el-input>
      </el-form-item>
      <el-form-item label="联系人邮箱">
        <el-input v-model="client.email"></el-input>
      </el-form-item>
      <el-form-item label="法人">
        <el-input v-model="client.legal"></el-input>
      </el-form-item>
      <el-form-item label="法人电话">
        <el-input v-model="client.legalphone"></el-input>
      </el-form-item>
      <el-form-item label="客户财务联系人">
        <el-input v-model="client.financecontacts"></el-input>
      </el-form-item>
      <el-form-item label="客户财务联系电话">
        <el-input v-model="client.financephone"></el-input>
      </el-form-item>
      <el-form-item label="开户银行">
        <el-input v-model="client.bank"></el-input>
      </el-form-item>
      <el-form-item label="银行账号">
        <el-input v-model="client.banknumber"></el-input>
      </el-form-item>
      <el-form-item label="当前状态">
        <el-select v-model="client.state" style="width: 100%">
          <el-option label="启用" value="启用"></el-option>
          <el-option label="未启用" value="未启用"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建人">
        <el-input v-model="client.creation"></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-input v-model="client.creationtime"></el-input>
      </el-form-item>
      <el-form-item label="版本">
        <el-input v-model="client.versions"></el-input>
      </el-form-item>
      <el-form-item label="修改时间">
        <el-input v-model="client.amendtime"></el-input>
      </el-form-item>
      <el-button
        type="primary"
        size="mini"
        icon="el-icon-close"
        @click="returnClient"
        >取消修改</el-button
      >
      <el-button
        type="primary"
        size="mini"
        icon="el-icon-check"
        @click="submitClient"
        >提交修改</el-button
      >
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cid: "",
      client: {},
    };
  },
  mounted() {
    this.cid = this.$route.params.cid;
    this.getClient();
  },
  methods: {
    //返回订单
    returnClient() {
      this.$router.push("/clientList");
    },

    //提交修改客户信息
    submitClient() {
      this.$confirm("是否要修改客户信息", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$axios.post("/client/modify", this.client).then((resp) => {
            if (resp.data.code == 200) {
              this.$message("修改成功");
              this.returnClient();
            }
          });
        })
        .catch(() => {
          this.$message("已取消修改");
        });
    },

    //查询客户信息
    getClient() {
      this.$axios
        .get("/client/getByCid", {
          params: {
            cid: this.cid,
          },
        })
        .then((resp) => {
          if (resp.data.code == 200) {
            this.client = resp.data.data;
          }
        });
    },
  },
};
</script>

<style>
</style>